package com.taotao.controller;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbItemParam;
import com.taotao.service.ItemParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Package com.taotao.controller
 * @Description:
 * @Author elwyn
 * @Date 2017/9/3 17:56
 * @Email elonyong@163.com
 */
@Controller
@RequestMapping("/item/param")
public class ItemParamController {
    @Autowired
    private ItemParamService itemParamService;

    @RequestMapping("/query/itemcatid/{itemCatId}")
    @ResponseBody
    public TaotaoResult getItemParamByCid(@PathVariable Long itemCatId) {
        TaotaoResult itemParamById = itemParamService.getItemParamById(itemCatId);
        return itemParamById;
    }

    @RequestMapping("/save/{cid}")
    @ResponseBody
    public TaotaoResult inertItemParam(@PathVariable Long cid, String paramData) {
        TbItemParam tbItemParam = new TbItemParam();
        tbItemParam.setItemCatId(cid);
        tbItemParam.setParamData(paramData);
        TaotaoResult taotaoResult = itemParamService.insertItemParam(tbItemParam);
        return taotaoResult;
    }
}
